var ScenePopup = function(options) {
	this.ctx = options.ctx;
	this.editor = options.editor;
	this.globe = options.editor.globe;
	this.sceneId=options.sceneId;
	this.dIndex;
	this.manage=new Map();
}

ScenePopup.prototype.switch= function(obj) {
	var _this=this;
	if(_this.isContain(obj.id)){
		_this.close(obj.id);
	}else{
		_this.create(obj);
	}
}

ScenePopup.prototype.isContain= function(id) {
	var _this=this;
	if(_this.manage.has(id)){
		return true;
	}
	return false;
}


ScenePopup.prototype.create= function(obj,type) {
	var _this=this;
	if(!_this.isContain(obj.id)){
        laytpl(tipsTPLScript.innerHTML).render(_this.formatHtml(obj,type), function (html) {
			let popup=_this.globe.createPopup({
				id:obj.id,
				position:obj.position,
				content:html,
			}); 
			popup.on('end',function(id){
				_this.manage.delete(id);
			});
			_this.manage.set(obj.id,popup);
        });
	}
}

ScenePopup.prototype.close= function(id) {
	var _this=this;
	if(_this.manage.has(id)){
		_this.manage.get(id).destroy();
		_this.manage.delete(id);
	}
}

ScenePopup.prototype.update= function(param) {
	var _this=this;
	if(param.id){
		if(_this.manage.has(param.id)){
			_this.manage.get(param.id).update(param);
		}
	}
}

ScenePopup.prototype.formatHtml=function(obj){
	let list=[];
	list.push({
		name:'名称',
		value:obj.name||'',
	});
	list.push({
		name:'标识',
		value:obj.code||'',
	});
	return list;
}




